{
  "metadata": {
    "kernelspec": {
      "name": "xpython",
      "display_name": "Python 3.13 (XPython)",
      "language": "python"
    },
    "language_info": {
      "name": ""
    }
  },
  "nbformat_minor": 5,
  "nbformat": 4,
  "cells": [
    {
      "id": "2865e5e4-d40e-45fc-9165-a4ddc8145735",
      "cell_type": "code",
      "source": "import qutip as qt\nimport numpy as np\nimport pandas as pd\n\n# Parameters (normalized units: omega_0=1 corresponds to ~1/ps scale; real omega_0 ~2.33e15 rad/s for 808 nm)\nomega_0 = 1.0  # Normalized energy splitting\nomega_L = 1.0  # Resonant laser frequency\nOmega = 0.2    # Rabi frequency (example value; proxy for fluence)\ngamma = 0.1    # Decoherence rate (example value)\ntimes = np.linspace(0, 50, 500)  # Normalized time (scalable to ps)\n\n# Operators for TLS\nsz = qt.sigmaz()\nsm = qt.sigmam()\nsp = qt.sigmap()\n\n# Hamiltonian (resonant in rotating frame)\nH = (omega_0 / 2) * sz + (Omega / 2) * (sp + sm)\n\n# Collapse operators for dissipation (spontaneous emission)\nc_ops = [np.sqrt(gamma) * sm]\n\n# Initial state: Ground state density matrix\nrho0 = qt.basis(2, 0) * qt.basis(2, 0).dag()\n\n# Solve master equation\nresult = qt.mesolve(H, rho0, times, c_ops=c_ops)\n\n# Extract observables\npop_excited = qt.expect(sp * sm, result.states)  # Excited population\ncoherence = np.real(qt.expect((sp + sm)/2, result.states))  # Real part of coherence\n\n# Create DataFrame for output (exportable to CSV/Excel)\ndata = pd.DataFrame({\n    'Time': times,\n    'Excited_Population': pop_excited,\n    'Coherence': coherence\n})\n\n# Export to CSV for verification (uncomment to save)\n# data.to_csv('tls_simulation_data.csv', index=False)\n\n# Print sample output (first 5 rows)\nprint(data.head())",
      "metadata": {
        "trusted": true
      },
      "outputs": [],
      "execution_count": null
    },
    {
      "id": "d8a7520f-3014-46e0-8ca1-04579c79feb6",
      "cell_type": "code",
      "source": "",
      "metadata": {
        "trusted": true
      },
      "outputs": [],
      "execution_count": null
    }
  ]
}